home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / Recursive Shell 1.0.1 / Recursive Shell ƒ / DialogUtil.c next >
Text File  |  1996-06-14  |  2KB  |  88 lines

  1. /*****************************************************************************/
  2. //
  3. //    DialogUtil.c
  4. //
  5. //    Various utility functions for displaying and handling dialog boxes.
  6. //
  7. //    Version 1.0
  8. //
  9. //    Created:    13 May 1996
  10. //    Modified:    14 June 1996
  11. //
  12. /*****************************************************************************/
  13.  
  14. //    Actually, put these in the Utilities.c file...
  15.  
  16. #include    "DialogUtil.h"
  17.  
  18. #define    kEmptyString    "\p"
  19. #define    kMoveToFront    (WindowPtr)-1L
  20. #define    kNilFilterProc    nil
  21. #define    kBaseResID        700
  22. #define    kErrorResID        kBaseResID
  23. #define    kAboutResID        kBaseResID
  24.  
  25. //
  26. //    DisplayFatalError
  27. //    Display a stop alert box with a single text string, then quit
  28. void DisplayFatalError( Str255 errorString )
  29. {
  30.     ParamText( errorString, kEmptyString, kEmptyString, kEmptyString );
  31.     StopAlert( kErrorResID, kNilFilterProc );
  32.     ExitToShell();
  33. }
  34.  
  35.  
  36. //
  37. //    DisplayAlert
  38. //
  39. void DisplayAlert( Str255 errorString )
  40. {
  41.     ParamText( errorString, kEmptyString, kEmptyString, kEmptyString );
  42.     StopAlert( kErrorResID, kNilFilterProc );
  43. }
  44.  
  45.  
  46. //
  47. //    ShowAboutBox
  48. //
  49. void    ShowAboutBox( void )
  50. {
  51.     DialogPtr    myDialog;
  52.     
  53.     /*    De-hilight the Apple menu    */
  54.     HiliteMenu( 0 );
  55.     
  56.     myDialog = GetNewDialog( kAboutResID, nil, kMoveToFront );
  57.     ShowWindow( myDialog );
  58.     DrawDialog( myDialog );
  59.     
  60.     /*    Wait until the user releases the mouse button.
  61.      *    If the user holds down the mouse when a click causes a message to be displayed,
  62.      *    we must wait until they release the button before checking for a click (see below)
  63.      *    to clear the dialog - so they at least have a chance to see it.
  64.      *    NOTE THE SEMICOLON!
  65.      *    This is a loop which waits until the mouse button is not down.
  66.      */
  67.     while ( Button() );
  68.     
  69.     /*    Now, wait until the user clicks:
  70.      *    NOTE THE SEMICOLON!
  71.      *    This is a loop which waits until the mouse is clicked.
  72.      */
  73.     while ( ! Button() );
  74.     
  75.     /*    Wait until the user releases the mouse button.
  76.      *    It seems a little funny to have the dialog go away on mouseDown.
  77.      *    This makes it seem more like a mouseUp thing.
  78.      *    NOTE THE SEMICOLON!
  79.      *    This is a loop which waits until the mouse button is not down.
  80.      */
  81.     while ( Button() );
  82.     
  83.     /*    clear the event queue so the click doesn't do anything:    */
  84.     FlushEvents( everyEvent, 0 );
  85.     
  86.     DisposeDialog( myDialog );    /*    Get rid of the dialog    */
  87. }
  88.